home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / internet / other / ka9q / ka9q_src.arc / GLOBAL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-28  |  2.1 KB  |  69 lines

  1. /* Global definitions used by every source file.
  2.  * Some may be compiler dependent.
  3.  */
  4.  
  5. /* Indexes into binmode in files.c; hook for compilers that have special
  6.  * open modes for binary files
  7.  */
  8. #define    READ_BINARY    0
  9. #define    WRITE_BINARY    1
  10. #define APPEND_BINARY    2
  11. extern char *binmode[];
  12.  
  13. /* These two lines assume that your compiler's longs are 32 bits and
  14.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  15.  * but it doesn't matter if they're signed or unsigned.
  16.  */
  17. typedef long int32;        /* 32-bit signed integer */
  18. typedef unsigned short int16;    /* 16-bit unsigned integer */
  19.  
  20. /* Since not all compilers support structure assignment, the ASSIGN()
  21.  * macro is used. This controls how it's actually implemented.
  22.  */
  23. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  24. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  25. #else            /* Version for compilers that do */
  26. #define    ASSIGN(a,b)    ((a) = (b))
  27. #endif
  28.  
  29. /* Define null object pointer in case stdio.h isn't included */
  30. #ifndef    NULL
  31. /* General purpose NULL pointer */
  32. #define    NULL (void *)0
  33. #endif
  34. #define    NULLCHAR (char *)0    /* Null character pointer */
  35. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  36. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  37. #define    NULLFILE (FILE *)0    /* Null file pointer */
  38.  
  39. /* General purpose function macros */
  40. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  41. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  42.  
  43. #ifdef    MPU8080    /* Assembler routines are available */
  44. int16 hinibble(),lonibble(),hibyte(),lobyte(),hiword(),loword();
  45.  
  46. #else
  47.  
  48. /* Extract a short from a long */
  49. #define    hiword(x)    ((int16)((x) >> 16))
  50. #define    loword(x)    ((int16)(x))
  51.  
  52. /* Extract a byte from a short */
  53. #define    hibyte(x)    (((x) >> 8) & 0xff)
  54. #define    lobyte(x)    ((x) & 0xff)
  55.  
  56. /* Extract nibbles from a byte */
  57. #define    hinibble(x)    (((x) >> 4) & 0xf)
  58. #define    lonibble(x)    ((x) & 0xf)
  59.  
  60. #endif
  61.  
  62. #if (SYS5 || (ATARI_ST && LATTICE))
  63. #define rindex    strrchr
  64. #define index    strchr
  65. #endif
  66.  
  67. /* Heavily used functions from the standard library */
  68. char *index(),*rindex(),*malloc(),*calloc(),*ctime(),*tmpnam();
  69.